﻿// <copyright file="IniFileTest.cs" company="DotNetLib">
//
// .netlib: http://www.codeplex.com/DotNetLib
//
// This code is released under the New BSD License.
// A copy of this license is available at:
// http://www.codeplex.com/DotNetLib/license
//
// </copyright>

namespace DotNetLib.Tests
{
  using System.IO;
  using DotNetLib.IO;
  using global::Microsoft.VisualStudio.TestTools.UnitTesting;

  /// <summary>
  /// This is a test class for DotNetLib.IO.IniFile.
  /// </summary>
  [TestClass()]
  public class IniFileTest : TestBase
  {
    private const string Filename = @"Sample.ini";
    private const string Filename2 = @"Sample2.ini";

    [ClassInitialize()]
    public static void Initialize(TestContext testContext)
    {
      File.WriteAllText(Filename, DotNetLib.Tests.Properties.Resources.SampleIni);
    }

    [ClassCleanup()]
    public static void Cleanup()
    {
      File.Delete(Filename);
    }

    /// <summary>
    /// A test for Load
    /// </summary>
    [TestMethod()]
    public void LoadTest()
    {
      IniFile target = new IniFile();
      target.Load(Filename);
      target.Save(Filename2);

      Assert.AreEqual(File.ReadAllText(Filename), File.ReadAllText(Filename2));

      File.Delete(Filename2);
    }
  }
}
